// 这个是用来干嘛的 就是给表单提供数据的
import { reactive, ref } from 'vue'
import useInstance from '@/hooks/useInstance';
import { editVersion } from '@/api/test/testModel'
import { EditType } from '@/type/BaseEnum'
import { editFileVersionApi } from '@/api/test/test'
export default function useVersionModel(getAuditList?,searchParams?) {
    const { global, proxy } = useInstance()
    const editVersionChild = ref<{ show: (type: string, row?: any) => void }>()
    const rules = reactive({
        version: [{
            required: true,
            message: '请输入要修改的版本号',
            trigger: 'blur',
        }],

    })
    const dialogModel = reactive<editVersion>({
        version: '',
        id: '',
    })
    const editVersionBtn = (row) => {
        console.log(row);

        // dialogModel.taskId = id
        editVersionChild?.value?.show(EditType.EDIT, row)
    }
    const saveEdutVersion = async (row) => {
        console.log(row);

        const res = await editFileVersionApi(row)
        if (res.code === 200) {
            console.log(res);
            global.$message({ message: '修改成功', type: 'success' })
            // getBaseline(row.taskId)
            getAuditList(searchParams.id, searchParams.taskBaselineId)
        }
    }
    return {
        rules, dialogModel, editVersionChild, editVersionBtn, saveEdutVersion
    }
}